"""
公共模型模块
定义项目中通用的基础模型类
"""

from django.db import models
from django.utils import timezone


class BaseModel(models.Model):
    """
    基础模型类
    包含所有模型的公共字段
    """
    created_at = models.DateTimeField(
        verbose_name="创建时间",
        default=timezone.now,
        help_text="记录创建时间"
    )
    updated_at = models.DateTimeField(
        verbose_name="更新时间",
        auto_now=True,
        help_text="记录最后更新时间"
    )
    is_active = models.BooleanField(
        verbose_name="是否激活",
        default=True,
        help_text="标记记录是否有效"
    )

    class Meta:
        abstract = True
        ordering = ['-created_at']


class TaskStatus(models.TextChoices):
    """任务状态枚举"""
    PENDING = 'pending', '待处理'
    RUNNING = 'running', '运行中'
    SUCCESS = 'success', '成功'
    FAILED = 'failed', '失败'
    CANCELLED = 'cancelled', '已取消'


class DataStatus(models.TextChoices):
    """数据状态枚举"""
    RAW = 'raw', '原始数据'
    PROCESSING = 'processing', '处理中'
    PROCESSED = 'processed', '已处理'
    VALIDATED = 'validated', '已验证'
    PUBLISHED = 'published', '已发布'
    ARCHIVED = 'archived', '已归档'
